﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BAL;
using DAL;
namespace blog
{
    //public partial class Index : blog.Class.PageBase
    public partial class Index :Class.PageProxy
    {
        public int num=1;
        
        protected void Page_Load(object sender, EventArgs e)
        {
            //DAL.DALPost dalpost = new DAL.DALPost(null);
            //dalpost.insertintoposts();
            Ajax.Utility.RegisterTypeForAjax(typeof(blog.Index));
           
        }
        [Ajax.AjaxMethod()]
        public int modifypost(string postid)
        {
            Dictionary<string, string> post = BAL.DoPost.getpost(Convert.ToInt32(postid));
            string postname = post["postname"].ToString();
            string postcontent = post["postcontent"].ToString();
            string postdate = post["postdate"].ToString();
            string postuser = post["postuser"].ToString();
            postuser = "dddddddddddddddddd";
            string id = post["postid"].ToString();
            Model.Post mypost = new Model.Post(id, postname, postcontent, postdate, postuser);
            return BAL.DoPost.modifypost(mypost);

        }

        [Ajax.AjaxMethod()]
        public void removecontrol(int id)
        {
          
        }
        [Ajax.AjaxMethod()]
        public string checkpostid(int id)
        {
            if (BAL.DoPost.checkpostid(id))
            {
                return "true";
            }
            else
                return "false";
        }
        [Ajax.AjaxMethod()]
        public int getmaxnum()
        {
            return BAL.DoPost.getmaxpost();  
        }
        [Ajax.AjaxMethod()]
        public int getminnum()
        {
            return BAL.DoPost.getminpost();
        }
        [Ajax.AjaxMethod()]
        public int getnextnum()
        {
            return num++;
        }
    }
}